package net.qhzw.vip.qiyu.service;


import com.alibaba.fastjson.JSON;
import lombok.extern.slf4j.Slf4j;
import net.qhzw.vip.qiyu.entity.SysUser;
import net.qhzw.vip.qiyu.handler.ApiException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

@Service
@Slf4j
public class AdminUserService {


    @Autowired
    private StringRedisTemplate redisTemplate;


    public SysUser getLoginUser(Long userId) {
        String userJson = redisTemplate.opsForValue().get("adminLogin_" + userId);



        if (StringUtils.isEmpty(userJson)) {
            throw new ApiException("您的登录信息已过期， 请重新登录！");
        }
        return JSON.parseObject(userJson, SysUser.class);

    }


}
